<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/css/plat-style.css" />
</head>
<body>

<div class="layui-container">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" id="iconAddForm">
                <input type="hidden" name="id" value="${icon.id}">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" autocomplete="off" class="layui-input" value="${icon.name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>图标位置</label>
                    <div class="layui-input-block">
                        <select name="position">
                            <option value="">请选择</option>
                            <c:forEach items="${iconList}" var="i">
                                <option value="${i.position}" ${icon.position==i.position?'selected':''}>${i.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>事件类型</label>
                    <div class="layui-input-block">
                        <select name="event" data-type="1">
                            <option value="" remark=" ">请选择</option>
                            <c:forEach items="${allList}" var="a">
                                <option value="${a.url}" remark="${a.remark}" ${icon.event==a.url?'selected':''}>${a.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>链接</label>
                    <div class="layui-input-block">
                        <input type="text" name="url" autocomplete="off" class="layui-input" value="${icon.url}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <span>注：<span id="tip" class="red"></span></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>首页显示</label>
                    <div class="layui-input-block">
                        <input type="radio" name="display" value="1" title="显示" checked>
                        <input type="radio" name="display" value="0" title="隐藏">
                    </div>
                </div>
                <hr>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>图片</label>
                    <div class="layui-input-block">
                        <label for="imgUrl" class="layui-btn layui-btn-sm layui-btn-primary">上传图片</label>
                        <input accept=".jpg,.png,.gif,.jpeg" type="file" style="display:none;" name="imgUrl" id="imgUrl"
                               onchange="showImg(this)"/>
                        <img id="img" src="${icon.icon==null?' ':icon.icon}" width="135px" height="135"/><br>
                        <span class="green">建议上传46*46尺寸大小的图片,格式支持jpg，png等</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" class="layui-input" value="${icon.sort}">
                        <span class="green">注：排序越高越靠前, (格式为:数字0-9，不能包含其他字符)</span>
                    </div>
                </div>
            </form>
            <div class="layui-form-item layui-layout-admin">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn" onclick="FormSubmit('#iconAddForm','/icon/editIcon')">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/plugins/image/previewImg.js"></script>
<script>
    layui.config({
        //静态资源所在路径
        base: '/layuiadmin/'
    }).extend({
        //主入口模块
        index: 'lib/index'
    }).use(['index', 'form'], function(){
        var $ = layui.$,layer = layui.layer,element = layui.element,form=layui.form;
        element.render();
        form.on('select',function (data) {
            //获取原生DOM对象
            var dom = data.elem;
            //获取事件下拉框被选中的'remark'值
            var remark = $(dom).find('option:selected').attr('remark');
            //'remark'值回显提示栏
            if(remark===" "){
                $("#tip").text("");
            }else{
                $("#tip").text(remark);
            }
        });
        form.render();
    });

    $(function () {
        //提示信息回显
        $("#tip").text($('select[name="event"]').find('option:selected').attr('remark'));
    });
</script>
</body>
</html>